package com.myFwk.controller;

import com.myFwk.model.LoginResult;
import com.myFwk.model.R;
import com.myFwk.service.serviceImpl.LoginServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author GL
 * @version 1.0
 * @date 2021/9/1 21:09
 */
@RestController
@Api(tags = "后台人员登录")
public class LoginController {

    @Autowired
    private LoginServiceImpl loginService;


    /**
     * RequestParam 指的是在路径上需要拼接参数
     * TODO 登录失败 账号密码错误
     *
     * @param username
     * @param password
     * @return
     */
    @PostMapping("/admin/login")
    public R<LoginResult> login(String username,
                                String password
    ) {
        LoginResult loginresult = loginService.login(username, password);
        return R.ok(loginresult);
    }


}
